package com.example.othree.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.othree.entity.CropsYieldYearData;
import com.example.othree.entity.JjjSitesInfo;
import com.example.othree.mapper.CropsYieldYearDataMapper;
import com.example.othree.mapper.JjjSitesInfoMapper;
import com.example.othree.service.JjjSitesInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zogran
 * @since 2024-11-12
 */
@Service
public class JjjSitesInfoServiceImpl extends ServiceImpl<JjjSitesInfoMapper, JjjSitesInfo> implements JjjSitesInfoService {
    @Resource
    JjjSitesInfoMapper jjjSitesInfoMapper;
    @Override
    public IPage PageList(IPage<JjjSitesInfo> page, Wrapper wrapper) {
        return jjjSitesInfoMapper.PageList(page,wrapper);
    }

    @Override
    public HashMap<String, Float[]> SitesInfoByCitys(String[] cities) {
        List<JjjSitesInfo> jjjSitesInfoList = jjjSitesInfoMapper.SitesInfoByCitys(cities);
        HashMap<String, Float[]> siteForId = new HashMap<>();
        for (JjjSitesInfo i : jjjSitesInfoList){
            siteForId.put(i.getSiteId(), new Float[]{i.getLon(), i.getLat()});
        }
        return siteForId;
    }

    @Override
    public HashMap<String, Float[]> SitesInfoAll() {
        List<JjjSitesInfo> jjjSitesInfoList = jjjSitesInfoMapper.SitesInfoAll();
        HashMap<String, Float[]> siteForId = new HashMap<>();
        for (JjjSitesInfo i : jjjSitesInfoList){
            siteForId.put(i.getSiteId(), new Float[]{i.getLon(), i.getLat()});
        }
        return siteForId;
    }
}
